package egg_drop;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class AnimDuck {
    
    public int x;
    
    public int y;    
   
    private int speed;
   
    private BufferedImage DuckImg;      
    
    private int duckImgWidth;
    
    private int duckImgHeight;
    
    private boolean left;
    
    public AnimDuck(int x, int y, int speed, BufferedImage DuckImg)
    {
        this.x = x;
        this.y = y;
        
        this.speed = speed;
        
        this.DuckImg = DuckImg;
        
        duckImgWidth = DuckImg.getWidth();
        duckImgHeight = DuckImg.getHeight();
        
        left = true;
        
    }
    
    public void Update()
    {
    	if ((x + duckImgWidth + 50) >= Framework.frameWidth && left == false)
			left = true;
		if ((x - duckImgWidth <= 0) && left == true)
			left = false;
		if (!left)
		{
			x += speed;
		}
		else
		{
			x -= speed;
		}
		y = 0;
    }
    
    public void Draw(Graphics2D g2d)
    {
        g2d.drawImage(DuckImg, x, y, null);
    }
}